package com.prezs.test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;

import com.prezs.annotation.Information;
import com.prezs.pojo.entity.Person;
import com.prezs.service.PersonService;

public class testJavaCustomAnno {
	
	public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		
		Class<?> clazz =  PersonService.class;
		try {
			Method method =  clazz.getMethod("outPutPersonInfo", Person.class);
			if(!method.isAnnotationPresent(Information.class)){
				System.out.println(method.getName()+"方法没有标注@Information注解");
				return;
			}
			Person person = new Person();
			Information information =  method.getAnnotation(Information.class);
			person.setName(information.name());
			person.setAge(information.age());
			person.setAddress(information.address());
			person.setHobbies(Arrays.asList(information.hobbies()).toString());
			PersonService personService = new PersonService();
			method.invoke(personService, person);
		} catch (NoSuchMethodException | SecurityException e) {
			e.printStackTrace();
		}
	}
}
